//
//  FirstTableViewCell.m
//  MarianasTrench
//
//  Created by wangjue on 16/3/17.
//  Copyright © 2016年 王爵. All rights reserved.
//

#import "FirstTableViewCell.h"

@interface FirstTableViewCell ()
@property (nonatomic, retain) UIImageView *leftImage;
@property (nonatomic, retain) UILabel *rightTopLabel;
@property (nonatomic, retain) UILabel *rightDownLabel;
@property (nonatomic, retain) UIView *backView;
@property (nonatomic, retain) UIImageView *roundImage;
@property (nonatomic, retain) UILabel *imageRightUpLabel;
@property (nonatomic, retain) UILabel *imageRightDownLabel;
@end

@implementation FirstTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubViews];
    }
    return self;
}


-(void)createSubViews{
    self.leftImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_leftImage];
    
    self.rightTopLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightTopLabel];
    
    self.rightDownLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_rightDownLabel];
    
    self.backView = [[UIView alloc] init];
    [self.contentView addSubview:_backView];
    
    self.roundImage = [[UIImageView alloc] init];
    [self.contentView addSubview:_roundImage];
    
    self.imageRightDownLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_imageRightDownLabel];
    
    self.imageRightUpLabel = [[UILabel alloc] init];
    [self.contentView addSubview:_imageRightUpLabel];
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    _leftImage.frame = CGRectMake(10, 10, self.contentView.frame.size.width / 5, 80);
    
    _rightTopLabel.frame = CGRectMake(_leftImage.frame.origin.x + self.contentView.frame.size.width / 5 + 10 , 20, 200, 20);
    
    _rightDownLabel.frame = CGRectMake(_rightTopLabel.frame.origin.x , _rightTopLabel.frame.origin.y + 20, self.contentView.frame.size.width / 1.5, 15);
    _rightDownLabel.textColor = [UIColor grayColor];
    _rightDownLabel.font = [UIFont systemFontOfSize:14];
    
    _backView.backgroundColor = [UIColor colorWithRed:0.97 green:0.97 blue:0.97 alpha:1];
    _backView.frame = CGRectMake(0, _leftImage.frame.origin.y + 80, self.contentView.frame.size.width, 70);
    
    _roundImage.frame = CGRectMake(20, _backView.frame.origin.y + 5, 40, 40);
    _roundImage.backgroundColor = [UIColor orangeColor];
    _roundImage.layer.cornerRadius = 20;
    _roundImage.layer.masksToBounds = YES;
    _roundImage.layer.borderWidth = 1;
    _roundImage.layer.borderColor = [UIColor grayColor].CGColor;
    
    _imageRightUpLabel.frame = CGRectMake(80, _backView.frame.origin.y + 5, 200, 20);
    _imageRightUpLabel.font = [UIFont systemFontOfSize:15];
    
    _imageRightDownLabel.frame = CGRectMake(80, _backView.frame.origin.y + 30, self.contentView.frame.size.width / 1.5, 30);
    _imageRightDownLabel.numberOfLines = 2;
    _imageRightDownLabel.font = [UIFont systemFontOfSize:12];
    _imageRightDownLabel.textColor = [UIColor blackColor];
    
    
                            
}

-(void)setModel:(ListenModel *)model{
    _model = model;
    
    [_leftImage sd_setImageWithURL:[NSURL URLWithString:_model.albumCover] placeholderImage:[UIImage imageNamed:@"no_network@3x"]];
    
    _rightTopLabel.text = _model.albumTitle;
    
    _rightDownLabel.text = _model.trackTitle;
    
    [_roundImage sd_setImageWithURL:[NSURL URLWithString:_model.avatar] placeholderImage:[UIImage imageNamed:@"no_network@3x"]];
    
    _imageRightUpLabel.text = _model.nickname;
    
    _imageRightDownLabel.text = _model.personalSignature;
    
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
